package com.epcm.admin.epcm.project.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.epcm.admin.epcm.project.mapper.ProjectMapper;
import com.epcm.admin.epcm.project.service.ProjectService;
import com.epcm.admin.epcm.project.entity.Project;
import com.epcm.admin.epcm.project.param.ProjectParam;
import com.epcm.admin.common.core.web.PageParam;
import com.epcm.admin.common.core.web.PageResult;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 项目清单Service实现
 *
 * @author linktoyl@163.com
 * @since 2023-10-18 01:39:33
 */
@Service
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements ProjectService {

    @Override
    public PageResult<Project> pageRel(ProjectParam param) {
        PageParam<Project, ProjectParam> page = new PageParam<>(param);
        //page.setDefaultOrder("create_time desc");
        List<Project> list = baseMapper.selectPageRel(page, param);
        return new PageResult<>(list, page.getTotal());
    }

    @Override
    public List<Project> listRel(ProjectParam param) {
        List<Project> list = baseMapper.selectListRel(param);
        // 排序
        PageParam<Project, ProjectParam> page = new PageParam<>();
        //page.setDefaultOrder("create_time desc");
        return page.sortRecords(list);
    }

    @Override
    public Project getByIdRel(Integer projectId) {
        ProjectParam param = new ProjectParam();
        param.setProjectId(projectId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
